//package com.zz.framework.widget.musicplayer
//
//import android.content.ComponentName
//import android.content.Context
//import android.content.Intent
//import android.content.ServiceConnection
//import android.os.Handler
//import android.os.IBinder
//import android.os.Looper
//import android.util.AttributeSet
//import android.view.LayoutInflater
//import android.view.View
//import android.widget.ImageView
//import android.widget.LinearLayout
//import android.widget.ProgressBar
//import com.zz.framework.R
//
///**
// * Copyright © 2025 zhun All rights reserved.
// * Created by ZhaoZhun on 2025/2/20 18:25.
// * @author: ZhaoZhun 1820022519@qq.com
// * @version: V1.0
// */
//class MusicPlayerView @JvmOverloads constructor(
//    context: Context,
//    attrs: AttributeSet? = null,
//    defStyleAttr: Int = 0
//) : LinearLayout(context, attrs, defStyleAttr), ServiceConnection {
//
//    private val handler = Handler(Looper.getMainLooper())
//    private var mediaService: MediaService? = null
//    private val isPlaying: Boolean
//        get() = mediaService?.isPlaying ?: false
//
//    private val playButton: ImageView by lazy { findViewById(R.id.ivPlay) }
//    private val pauseButton: ImageView by lazy { findViewById(R.id.ivPause) }
//    private val progressBar: ProgressBar by lazy { findViewById(R.id.progressBar) }
//
//    init {
//        LayoutInflater.from(context).inflate(R.layout.view_music_player, this, true)
//        setupListeners()
//        bindMediaService()
//    }
//
//    private fun setupListeners() {
//        playButton.setOnClickListener { play() }
//        pauseButton.setOnClickListener { pause() }
//    }
//
//    private fun bindMediaService() {
//        val intent = Intent(context, MediaService::class.java)
//        context.startService(intent)
//        context.bindService(intent, this, Context.BIND_AUTO_CREATE)
//    }
//
//    fun play() {
//        mediaService?.play()
//        updateUI(true)
//    }
//
//    fun pause() {
//        mediaService?.pause()
//        updateUI(false)
//    }
//
//    private fun updateUI(isPlaying: Boolean) {
//        playButton.visibility = if (isPlaying) View.GONE else View.VISIBLE
//        pauseButton.visibility = if (isPlaying) View.VISIBLE else View.GONE
//    }
//
//    override fun onServiceConnected(name: ComponentName?, service: IBinder?) {
//        mediaService = (service as? MediaService.LocalBinder)?.getService()
//    }
//
//    override fun onServiceDisconnected(name: ComponentName?) {
//        mediaService = null
//    }
//
//    override fun onDetachedFromWindow() {
//        super.onDetachedFromWindow()
//        context.unbindService(this)
//    }
//}
